package net.sourceforge.m2settings;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;

import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.ValidationException;

public class XMLBinder {
	public String toXMLString(Object obj) throws IOException, MarshalException, ValidationException {
		StringWriter w = new StringWriter();
		writeXML(obj, w);
		return w.toString();
	}

	public void writeXML(Object obj, Writer w) throws IOException, MarshalException, ValidationException {
		Marshaller marshaller = new Marshaller(w);
		marshaller.marshal(obj);		
	}
}
